
package SGDB ;

use 5.6.0 ;
use warnings ;
use strict ;
use integer ;
use bytes ;

use Sgdb::GdbExt ;
use Sgdb::LocalConfig;

*localconfig = \&Sgdb::LocalConfig::local_config  ;

sub getip($) {
    my $addr = shift ;
    localconfig( 'qa-get-ip-by-name', $addr ) || $addr
}

sub Sgdb::GdbExt::target {

    my $gdb  = shift or die 'no object?' ;
    my $addr = shift ;
    my $dir  = shift || 'D01a' ;
    $addr =~ s/\-slc\b//i and @ENV{qw/SLC_CRED SLC_PASS/} = Sgdb::LocalConfig::slc_weekly() ;
    my $cred = $ENV{SLC_CRED} && $ENV{SLC_PASS} ? " $ENV{SLC_CRED} $ENV{SLC_PASS}" : '' ;

    $addr = getip $addr or die "no valid addr" ;
    my $cmd = "target symmetrix $addr:$dir $cred" ;
    print $cmd, "\n" ;
    $gdb -> get ( $cmd ) ;
}


sub new {
    my $self = shift ;
    new Sgdb::GdbExt localconfig ('parameterize', -params => " -q -nx -nw --readnow", @_) 
}

sub Sgdb::GdbExt::get_event {
    die "can't load Sgdb::EVENTS: $@\n"
      unless require Sgdb::EVENTS ;
    &Sgdb::EVENTS::get_event
}

sub Sgdb::GdbExt::getEv {
    die "can't load Sgdb::EVENTS: $@\n"
      unless require Sgdb::EVENTS ;
    &Sgdb::EVENTS::getEv
}

